package beans

import (
	"github.com/gin-gonic/gin"
	"net/http"
)

// Result 结构体
type Result struct {
	Success bool        `json:"success"`
	Code    int         `json:"code"`
	Msg     string      `json:"msg"`
	Data    interface{} `json:"data"`
}

// Success 成功 带参数
func Success(c *gin.Context, data interface{}) {
	c.JSON(200, &Result{
		Success: true,
		Code:    200,
		Msg:     "成功",
		Data:    data,
	})
}

// Fail 失败 带参数
func Fail(c *gin.Context, data interface{}) {
	c.JSON(http.StatusBadRequest, &Result{
		Success: false,
		Code:    -1,
		Msg:     "失败",
		Data:    data,
	})
}
